WPF and Silverlight Edition Basic Library > Combo Box > ComboBox Features > ComboBox Items > Adding Items |
There are several ways to add items to the C1ComboBox control:
XAML Copy Code <c1:C1ComboBoxItem Height="25" Content="C1ComboBoxItem"/> <c1:C1ComboBoxItem Height="25" Content="C1ComboBoxItem"/> <c1:C1ComboBoxItem Height="25" Content="C1ComboBoxItem"/> <c1:C1ComboBoxItem Height="25" Content="C1ComboBoxItem"/>
C# Copy Codeusing C1.WPF;
Visual Basic Copy Code Imports C1.WPF
C# Copy Code c1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem1" }); c1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem2" }); c1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem3" }); c1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem4" });
Visual Basic Copy Code C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem1"}) C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem2"}) C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem3"}) C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem4"})
C# Copy Code Using C1.Silverlight;
Visual Basic Copy Code Imports C1.Silverlight
C# Copy Code C1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem1" }); C1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem2" }); C1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem3" }); C1ComboBox1.Items.Add(new C1ComboBoxItem() { Content = "C1ComboBoxItem4" });
Visual Basic Copy Code C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem1"}) C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem2"}) C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem3"}) C1ComboBox1.Items.Add(New C1ComboBoxItem() With {.Content = "C1ComboBoxItem4"})
Complete the following steps:
Visual Basic Copy Code Imports System.Collections.Generic
C# Copy Codeusing System.Collections.Generic;
Visual Basic Copy Code Dim dropDownList As New List(Of String)() dropDownList.Add("C1ComboBoxItem1") dropDownList.Add("C1ComboBoxItem2") dropDownList.Add("C1ComboBoxItem3") dropDownList.Add("C1ComboBoxItem4")
C# Copy Code List<string> dropDownList = new List<string>(); dropDownList.Add("C1ComboBoxItem1"); dropDownList.Add("C1ComboBoxItem2"); dropDownList.Add("C1ComboBoxItem3"); dropDownList.Add("C1ComboBoxItem4");
Visual Basic Copy Code C1ComboBox1.ItemsSource = dropDownList
C# Copy Code c1ComboBox1.ItemsSource = dropDownList;